var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var ResKeeper = require("AA_ResKeeper");
var Const_Game = require("AA_Const_Game");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var BuffMag = require("AA_BuffMag");
var Item_CPBuff = require("AA_Item_CPBuff");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
_decorator.property;
_decorator.inspector;
var _def_CPBuffControl = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.hideArray = [];
    t.currShowMap = new Map();
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.CheckBuff = function (e, t) {
    var o = this;
    if (e == Const_Game.FruitId.紫薯精 && BuffMag.BuffMgr.isHaveShuiGuoBuff(72)) {
      var n = !this.currShowMap.has(e);
      n && this.currShowMap.set(e, new Map());
      var i = [];
      t.dressUpEquipMap.forEach(function (n) {
        if (n.equipData.shuiguoId == Const_Game.FruitId.紫薯精) {
          var a = t.JustCheck(n.equipData.lockCellIndex, Const_Game.BuffCheckType.正上下);
          if (a && a.length > 0) {
            var r = [];
            a.forEach(function (e) {
              var o = t.cellCompMap.get(e);
              o && o.equipComp && o.equipComp.equipData.equipLevel == GameGlobalVariable.GameGlobalVariable.normalMaxLevel && o.equipComp.equipData.shuiguoId == Const_Game.FruitId.至尊棒 && r.push(o.equipComp.node);
            });
            if (r && r.length > 0) {
              if (o.currShowMap.get(e).has(n.node.uuid)) {
                o.currShowMap.get(e).get(n.node.uuid).StartSet(n.node, r);
              } else {
                o.ShowOneBuff(n.node, r, e);
              }
              i.push(n.node.uuid);
            }
          }
        }
      });
      if (!n) {
        var a = this.currShowMap.get(e);
        a.forEach(function (e, t) {
          if (-1 == i.indexOf(t)) {
            e.unscheduleAllCallbacks();
            o.TakeBack(e.node);
            a.delete(t);
          }
        });
      }
    }
  };
  _creator.prototype.ShowOneBuff = function (e, t, o) {
    var n = this;
    if (this.hideArray.length > 0) {
      var i = this.hideArray.shift().getComponent(Item_CPBuff.default);
      i.StartSet(e, t);
      this.currShowMap.get(o).set(e.uuid, i);
    } else if (this.itemPfb) {
      this.MakeOnePfb(e, t, o);
    } else {
      this._loadRes(BundleConfig.BundleNames.Game, "game/" + "item/item_cpBuff", cc.Prefab).then(function (i) {
        n.itemPfb = i;
        n.MakeOnePfb(e, t, o);
      });
    }
  };
  _creator.prototype.MakeOnePfb = function (e, t, o) {
    var n = cc.instantiate(this.itemPfb);
    n.parent = this.node;
    var i = n.getComponent(Item_CPBuff.default);
    i.StartSet(e, t);
    this.currShowMap.get(o).set(e.uuid, i);
  };
  _creator.prototype.TakeBack = function (e) {
    e.active = false;
    this.hideArray.push(e);
  };
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_CPBuffControl;